﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lacrima.Gobang.App
{
    public class Stone
    {
        public Graphics graphics { get; set; }

        internal Image whiteStone { get; set; }

        internal Image blackStone { get; set; }

        public Image WhiteStone
        {
            get
            {
                Bitmap iStoneGrphices = global::Lacrima.Gobang.App.Properties.Resources.whitestone;
                return iStoneGrphices;
            }
        }

        public Image BlackStone
        {
            get
            {
                Bitmap iStoneGrphices = global::Lacrima.Gobang.App.Properties.Resources.blackstone;
                return iStoneGrphices;
            }
        }


        public Stone(Graphics g)
        {
            //构造函数
            whiteStone = WhiteStone;
            blackStone = BlackStone;
            graphics = g;
        }

        /// <summary>
        /// x,y为计算后的棋子的位置,flag判断棋子黑(true)白(false),+24为菜单点去24个高度
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="flag"></param>
        public void DrawStone(int m, int n, bool flag, int stepnum)
        {
            Brush bh;
            Font f;
            //数字的位置
            int numX = 0, numY = 0;
            if (stepnum < 10)
            {
                numX = 14; numY = 13;
            }
            if (stepnum >= 10 && stepnum < 100)
            {
                numX = 11; numY = 13;
            }
            if (stepnum >= 100)
            {
                numX = 8; numY = 13;
            }
            if (flag)
            {
                graphics.DrawImage(blackStone, m * 40, (n * 40) + 24, blackStone.Width, blackStone.Height);
                bh = new SolidBrush(Color.White);
                f = new Font("宋体", 10);
                graphics.DrawString(stepnum.ToString(), f, bh, m * 40 + numX, (n * 40) + 24 + numY);
            }
            else
            {
                graphics.DrawImage(blackStone, m * 40, (n * 40) + 24, blackStone.Width, blackStone.Height);
                bh = new SolidBrush(Color.Black);
                f = new Font("宋体", 10);
                graphics.DrawString(stepnum.ToString(), f, bh, m * 40 + numX, (n * 40) + 24 + numY);
            }
        }

    }
}
